#ifndef __LINKTREE_H_
#define __LINKTREE_H_

#include<string>

#include"DynamicArray.h"

#include<iostream>


using ElementType = std::string;

class TreeNode
{
private:

ElementType data;//数据域

TreeNode* parent; //双亲指针
TreeNode* FirstChild;  //孩子指针
TreeNode* nextSbling; //下一个兄弟指针




 

public:

static TreeNode *FindNode(TreeNode *node,const ElementType& element);

static void FindNode(TreeNode *node,const ElementType& element,DARRY::DynamicArray& a);


void Connect(TreeNode* parent);//将一个节点绑定为另一个节点的孩子
void DisConnect(TreeNode* parent); //将一个节点 解绑

TreeNode(const ElementType& element);

void show(TreeNode* node,int depth);

static void FreeNode(TreeNode* node);

static int GetNodeHeight(TreeNode* node);
TreeNode * GetParent();

std::string & GetData();
void SetData(const ElementType& element);
};




class LinkTree
{
    public:
    
    LinkTree();
    LinkTree(const ElementType& element);

    TreeNode * GetRoot();

    void show();

    ~LinkTree();

    DARRY::DynamicArray FindByElementType(const ElementType& element);

    int GetTreeHeight();

    std::string GetNodePath(TreeNode* node);

    private:

    TreeNode* root;
    
   

};



































































#endif